
import styles from './index.css';
import 'antd/dist/antd.css';
import React, { PureComponent } from 'react'
import { connect } from 'dva';
import {
  Table
} from 'antd';


const columns = [
  {
    title: '编号',
    dataIndex: 'name',
    key: 'name',
  },
  {
    title: '名称',
    dataIndex: 'age',
    key: 'age',
  },
  {
    title: '状态',
    dataIndex: 'address',
    key: 'address',
  },
  {
    title: '时间',
    dataIndex: 'time',
    key: 'time',
  },
  {
    title: '类型',
    dataIndex: 'type',
    key: 'type',
  }

];
class ChannelPage extends React.PureComponent {
  //创建的生命周期
  constructor(props) {
    super(props);
    this.state = {
      dataSource: [],
      current: 1,
      page: 0,
    };
    const { num, dispatch } = props;
  }
  //渲染
  render() {
    return (
      <Table dataSource={dataSource} columns={columns} pagination={{
        pageSize: 1,
        total: 5,
        current: this.state.current,
        onChange: this.changePage,
      }} />
    );
  }
  //组件卸载，用于没存回收
  componentWillUnmount() {

  }
  //  //组件将要被重新渲染
  //  shouldComponentUpdate(){

  //  }


  //  getSnapshotBeforeUpdate(){

  //  }
  //组件要被重新渲染
  componentDidUpdate() {

  }

  componentDidCatch() {

  }

  forceUpdate() {

  }
  //组件要接收到新属性
  componentWillReceiveProps() {

  }

  componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'channel/fetchChannel',
      payload: { ...this.state.page}
    }
  }

  changePage(page) {

  }
  changePage = (page) => {
    console.log("执行了么:" + page);
    this.setState({
      current: page,
    });

  }
}

//字面意思就是，把models的state变成组件的props
function mapStateToProps(state) {
  const { num } = state.channel // test就是models命名空间名字 
  const { } = state.channel
  return {
    num, // 在这return,上面才能获取到
  }
}
export default connect(mapStateToProps)(ChannelPage)   
